﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Model.MetadataTypes;
namespace Model.Entities
{
    /// <summary>
    /// 实体类 无线电监测设备信息表, 此类请勿动，以方便表字段更改时重新生成覆盖
    /// </summary>
    [Serializable]
    [MetadataType(typeof(RMBT_FACILITY_EQUIPMENT_Metadata))]
    public partial class RMBT_FACILITY_EQUIPMENT
    {
        /// <summary>
        /// 创建<see cref="RMBT_FACILITY_EQUIPMENT"/>的实例
        /// </summary>
        public RMBT_FACILITY_EQUIPMENT()
        {
                _rmbt_facility_antennaCollection = new List<RMBT_FACILITY_ANTENNA>();
		                }
        /// <summary>
        /// 监测设备ID【主键，系统GUID】
        /// </summary>
        public virtual string EQUID { get; set; }

        		
        /// <summary>
        /// 设备型号
        /// </summary>
        public virtual string EQUMODEL { get; set; }

    		
        /// <summary>
        /// 设备制造厂商
        /// </summary>
        public virtual string EQUIMANU { get; set; }

    		
        /// <summary>
        /// 设备序列号
        /// </summary>
        public virtual string EQUSN { get; set; }

    		
        /// <summary>
        /// 设备类型【外键：RMBT_CODE_EQUTYPE(CODE_ID)】
        /// </summary>
        public virtual string EQUTYPE { get; set; }

    		
        /// <summary>
        /// 测向定位设备工作模式【外键：RMBT_CODE_EQUWORKMODE(CODE_ID)】
        /// </summary>
        public virtual string EQUWORKMODE { get; set; }

    		
        /// <summary>
        /// 监测最大中频带宽
        /// </summary>
        public virtual decimal? IFBAND { get; set; }

    		
        /// <summary>
        /// 测向带宽
        /// </summary>
        public virtual decimal? DFBAND { get; set; }

    		
        /// <summary>
        /// 设备IP地址
        /// </summary>
        public virtual string EQUIP { get; set; }

    		
        /// <summary>
        /// 设备控制端口
        /// </summary>
        public virtual decimal? EQUPORT { get; set; }

    		
        /// <summary>
        /// 工作频段起始频率
        /// </summary>
        public virtual decimal STARTFREQ { get; set; }

    		
        /// <summary>
        /// 工作频段终止频率
        /// </summary>
        public virtual decimal ENDFREQ { get; set; }

    		
        /// <summary>
        /// 设备状态【外键：RMBT_CODE_STATUS(CODE_ID)】
        /// </summary>
        public virtual string EQUSTATUS { get; set; }

            /// <summary>
        /// 无线电监测设施基本表
        /// </summary>
        public virtual RMBT_FACILITY RMBT_FACILITY { get; set; }
		            private IList<RMBT_FACILITY_ANTENNA> _rmbt_facility_antennaCollection;
        /// <summary>
        /// 无线电监测天线信息表的集合
        /// </summary>
        public virtual ReadOnlyCollection<RMBT_FACILITY_ANTENNA> RMBT_FACILITY_ANTENNACollection { get { return new ReadOnlyCollection<RMBT_FACILITY_ANTENNA>(_rmbt_facility_antennaCollection); } }
		            /// <summary>
        /// 添加一个无线电监测天线信息表
        /// </summary>
        /// <param name="rmbt_facility_antenna">要添加的无线电监测天线信息表</param>
        /// <exception cref="ArgumentNullException"><paramref name="rmbt_facility_antenna"/>值为null。</exception>
        /// <exception cref="ArgumentException"><paramref name="rmbt_facility_antenna"/>已经被添加到某个<see cref="RMBT_FACILITY_ANTENNA"/>当中。</exception>
        public virtual void AddRMBT_FACILITY_ANTENNA(RMBT_FACILITY_ANTENNA rmbt_facility_antenna)
        {
            if (rmbt_facility_antenna == null)
            {
                throw new ArgumentNullException("rmbt_facility_antenna");
            }
            rmbt_facility_antenna.GetRMBT_FACILITY_EQUIPMENTCollection().Add(this);
            _rmbt_facility_antennaCollection.Add(rmbt_facility_antenna);
        }

        /// <summary>
        /// 移除一个无线电监测天线信息表
        /// </summary>
        /// <param name="rmbt_facility_antenna">要移除的无线电监测天线信息表</param>
        /// <returns>如果已成功移除<paramref name="rmbt_facility_antenna"/>，则为 true；否则为 false。 如果没有找到<paramref name="rmbt_facility_antenna"/>，该方法也会返回 false。</returns>
        /// <exception cref="ArgumentNullException"><paramref name="rmbt_facility_antenna"/>值为null。</exception>
        public virtual bool RemoveRMBT_FACILITY_ANTENNA(RMBT_FACILITY_ANTENNA rmbt_facility_antenna)
        {
            if (rmbt_facility_antenna == null)
            {
                throw new ArgumentNullException("rmbt_facility_antenna");
            }
            bool result = _rmbt_facility_antennaCollection.Remove(rmbt_facility_antenna);
            if(result)
            {
                rmbt_facility_antenna.GetRMBT_FACILITY_EQUIPMENTCollection().Remove(this);
            }
            return result;
        }

		/// <summary>
        /// 清空【无线电监测天线信息表】集合
        /// </summary>
        /// <returns>移除的【无线电监测天线信息表】条数</returns>
		public virtual int ClearRMBT_FACILITY_ANTENNACollection()
		{
            int count = _rmbt_facility_antennaCollection.Count;
            foreach (var rmbt_facility_antenna in _rmbt_facility_antennaCollection)
            {
                rmbt_facility_antenna.GetRMBT_FACILITY_EQUIPMENTCollection().Remove(this);
            }
            _rmbt_facility_antennaCollection.Clear();
            return count;
        }

		
        public override bool Equals(object obj)
        {
            RMBT_FACILITY_EQUIPMENT model = obj as RMBT_FACILITY_EQUIPMENT;
            return model != null && (ReferenceEquals(EQUID,null) ? ReferenceEquals(model.EQUID, null) : EQUID.Equals(model.EQUID));
        }
        public override int GetHashCode()
        {
            int hash = GetType().GetHashCode();
            hash = (hash * 397) ^ (ReferenceEquals(EQUID, null) ? 0 : EQUID.GetHashCode());
            return hash;
        }
    }
}
